package com.jingbian.cppccbackend.mapper.admin;

import com.jingbian.cppccbackend.entity.News;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 新闻表，用于存储新闻信息 Mapper 接口
 * </p>
 *
 * @author yezi
 * @since 2025-03-03
 */
@Mapper
public interface adminNewsMapper extends BaseMapper<News> {

    List<News> getNews(String sortType, String startDate, String endDate, String searchText);

    @Delete("delete from news where nid = #{nid}")
    void delete(Integer nid);

    @Update("UPDATE news SET title = #{news.title}, summary = #{news.summary} ,author = #{news.author},cover_image=#{news.coverImage},content = #{news.content}, updated_at=now() where nid = #{nid}")
    void updateNews(Integer nid, News news);
}
